package com.free.viewmover;

import com.free.app.MoveItemLayout;

import android.graphics.Canvas;
import android.graphics.Matrix;


public class FlipMover
{
	// mMotionType 
	public static final int FILL_MOTION = 0x00000000;
	public static final int SMOOTH_MOTION = 0x00000001;
	
	// mMoverType
	public static final int HORIZONTAL_MOVER = 0x00000000;
	public static final int VERTICAL_MOVER = 0x00000001;	
	
	protected int mMoverType;
	protected int mMotionType = FILL_MOTION;
	
	protected Matrix mAniMatrix = new Matrix();
	boolean mIsFirstMove = true;
	MoveItemLayout mMasterView;
	
	
	public FlipMover(MoveItemLayout view)
	{		
		mMasterView = view;
	}

	public int getMoverType()
	{
		return mMoverType;
	}	
	
	public void setMotionType(int motionType)
	{
		mMotionType = motionType;
	}
	
	public int getMotionType()
	{
		return mMotionType;
	}
	
	public MoveItemLayout getMasterView()
	{
		return mMasterView;
	}
	
	public Matrix getAniMatrix()
	{
		return mAniMatrix;
	}
	
	public void move(Canvas canvas)
	{
		if( mIsFirstMove )
		{
			mIsFirstMove = false;
			Matrix canvasMatrix = canvas.getMatrix();
			float[] values = new float[9];
			canvasMatrix.getValues(values);
			mAniMatrix.postTranslate(values[Matrix.MTRANS_X], values[Matrix.MTRANS_Y]); 
		}
		canvas.setMatrix(mAniMatrix);
	}
	
	public void appalyAniItem(AniItem item)
	{
		item.applyAni(this);
	}
}
 